package org.example.controller;

import jakarta.annotation.Resource;
import org.example.pojo.VideoInteraction;
import org.example.service.VideoInteractionService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 视频互动控制器
 *
 * @author rjs
 */
@RestController
@RequestMapping("/videoInteraction")
public class VideoInteractionController {

    @Resource
    private VideoInteractionService videoInteractionService;

    /**
     * 保存视频互动记录
     *
     * @param videoInteraction 视频互动记录
     * @return 保存是否成功
     */
    @PostMapping
    public boolean save(@RequestBody VideoInteraction videoInteraction) {
        return videoInteractionService.save(videoInteraction);
    }

    /**
     * 根据ID查询视频互动记录
     *
     * @param id 记录ID
     * @return 视频互动记录
     */
    @GetMapping("/{id}")
    public VideoInteraction getById(@PathVariable Long id) {
        return videoInteractionService.getById(id);
    }

    /**
     * 更新视频互动记录
     *
     * @param videoInteraction 视频互动记录
     * @return 更新是否成功
     */
    @PutMapping
    public boolean updateById(@RequestBody VideoInteraction videoInteraction) {
        return videoInteractionService.updateById(videoInteraction);
    }

    /**
     * 根据ID删除视频互动记录
     *
     * @param id 记录ID
     * @return 删除是否成功
     */
    @DeleteMapping("/{id}")
    public boolean removeById(@PathVariable Long id) {
        return videoInteractionService.removeById(id);
    }

    /**
     * 获取所有视频互动记录
     *
     * @return 视频互动记录列表
     */
    @GetMapping
    public List<VideoInteraction> listAll() {
        return videoInteractionService.list();
    }

}
